package com.spring.housing1.controller.commen;

import com.spring.housing1.constant.Constants;
import com.spring.housing1.constant.PageRequired;
import com.spring.housing1.constant.ServiceTokenRequired;
import com.spring.housing1.constant.isNull;
import com.spring.housing1.deliver.PitureEnhance;
import com.spring.housing1.returnType.CommenResult;

import com.spring.housing1.server.LoginServe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Map;


/**
* 查询接口
* */

@RestController
public class QueryControl {

    private final Logger log = LoggerFactory.getLogger(QueryControl.class);

    @Autowired
    LoginServe loginServer;

    /**
    * 登录web端
    * */
    @PostMapping("/loginIn")
    CommenResult<Object> login(@RequestBody Map<String,String> param, HttpSession httpSession) throws Exception {
           return  loginServer.doLogin(param,httpSession);
    }

    /**
     * 登录web端展示首页数据
     * */
    @GetMapping("/showIndex")
    CommenResult<Object> showIndex()  {
        return  loginServer.showIndex();
    }
    /**
     * doctor_type 2为影像科，3为内外科,
     * doctor_id 医师id
     * 登录web端个人展示数据
     * */
//    @ServiceTokenRequired
    @GetMapping("/showSelfindex")
    CommenResult<Object> showSelfindex(@RequestParam Map<String,String> param)  {
        return  loginServer.showSelfindex(param);
    }

    /**
    * 查询医生信息
    * */
    @ServiceTokenRequired
    @PageRequired
    @GetMapping("/pageQuery")
    CommenResult<Object> pageQuery(@RequestParam Map<String,String> param) throws Exception {
       log.info("分页页码:{} 分页大小:{}",Constants.pageNum,Constants.pageSize);

        CommenResult<Object> objectCommenResult = loginServer.queryRoleDoctor(param);

     return objectCommenResult;
    }


    /**
     * 登录完查询信息信息
     * */

    @GetMapping("/queryLoginUserInfo")
    @isNull({"id"})
    CommenResult<Object> queryLoginUserInfo(@RequestParam Map<String,String> param) throws Exception {
        CommenResult<Object> objectCommenResult = loginServer.queryLoginUserInfo(param);
        return objectCommenResult;
    }



    /**
     * 查询科室信息
     * */
    @ServiceTokenRequired
    @PageRequired
    @GetMapping("/roomQuery")
    CommenResult<Object> roomQuery(@RequestParam Map<String,String> param) throws Exception {
        log.info("分页页码:{} 分页大小:{}",Constants.pageNum,Constants.pageSize);

        CommenResult<Object> objectCommenResult = loginServer.queryRoom(param);

        return objectCommenResult;
    }


    /**
     * 病单查询
     * */
//    @ServiceTokenRequired
    @ServiceTokenRequired
    @PageRequired
    @GetMapping("/orderQuerys")
    CommenResult<Object> orderQuery(@RequestParam Map<String,String> param) {

     CommenResult<Object> objectCommenResult = loginServer.orderQuery(param);

        return objectCommenResult;
    }


    /**
     * 病单查询
     * */
//    @ServiceTokenRequired
    @ServiceTokenRequired
    @PageRequired
    @isNull({"doctor_type"})
    @GetMapping("/myOrderQuerys")
    CommenResult<Object> myOrderQuerys(@RequestParam Map<String,String> param) {

        CommenResult<Object> objectCommenResult = loginServer. myOrderQuerys(param);

        return objectCommenResult;
    }


    //    @ServiceTokenRequired
//
//    @GetMapping("/myOrderQuerys1")
//    CommenResult<Object> myOrderQuerys1(@RequestParam("path") String path) throws Exception {
//
//        PitureEnhance.getImage(path);
//        return null;
//    }

}
